<template>
   <div>
  <h3>审核时长</h3>
<p class="xx" >任务名称{{ formdata.taskName }}</p>

  <el-table :data="formdata" border style="width: 100%">
            <el-table-column label="序号" type="index"></el-table-column>
            <el-table-column label="姓名" prop="realName" ></el-table-column>
            <el-table-column label="任务名称" prop="taskName"></el-table-column>
            <el-table-column label="任务地点" :formatter='formatTaskCityDistrict'></el-table-column>
            <el-table-column label="时长" prop="finalDuration"></el-table-column>
            <!-- <el-table-column label="附加时长" prop="__EMPTY_4"></el-table-column>
            <el-table-column label="系数" prop="__EMPTY_7"></el-table-column>
            <el-table-column label="总时长" prop="__EMPTY_5"></el-table-column>
            <el-table-column label="备注" prop="__EMPTY_6"></el-table-column> -->


        </el-table>
        <div>总时长{{ xiaoshi }}</div>
        <el-row>
            <el-col :span="6">
                <el-button @click="tijiao">确定</el-button>
            </el-col>
            <el-col :span="6">
                <el-button @click="close">取消</el-button>
            </el-col>
        </el-row>
   </div>
</template>

<script>
import { huodeshichang,jiaoshichang } from '@/api';
export default {
    props: ['info','duration','startT'],
    data() {
        return {
            params: {
                taskId: '',
                durationStatus: ''
            },
            formdata:{
             
            startTime:'',
            extraDuration:0,
            finalDuration:0 ,
            coefficient:0,
            realName:''
        }

            
        }
    },
    methods: {

        formatTaskCityDistrict(row, column, cellValue) {
      // 假设 taskCity 和 taskDistrict 是 row 对象的属性
      return `${row.taskCity} - ${row.taskDistrict}`;
    },
    close() {
            this.$emit("done1")
        },
        tijiao(){
            console.log(this.formdata,444444555);
            
            jiaoshichang(this.formdata).then(res=>{
            
                
                console.log(res,99118866);
                
            })
        },

        gethuoqu() {
            console.log(this.info,55555);
            console.log(this.duration,6666);
           this.startTime =this.startT
            this.params.taskId = this.info;
            this.params.durationStatus = this.duration;
            console.log(   this.params.durationStatus,119988);
       
            console.log( this.params.taskId,99988);
            
            huodeshichang(this.params).then(res => {
                console.log(res.data);
this.formdata=res.data
console.log(this.formdata,99999111);
this.formdata = res.data.map(item => ({

...item, // 保留 item 的所有现有属性

extraDuration: item.extraDuration || 0, // 如果不存在，则设置为 0

finalDuration: item.finalDuration || 0, // 如果不存在，则设置为 0

coefficient: item.coefficient || 0 ,// 如果不存在，则设置为 0
remark:item.remark||'',
realName:item.memberName||'',
durations:item.durations||0
}));
// console.log(this.formdata.__ob__.dep.subs,333333);


            })
        }
    },
    
    mounted(){
  
        this.gethuoqu()
    },
    computed: {
        xiaoshi() {
            return this.formdata.reduce((pre, next) => pre + next.finalDuration, 0)
        }
    }


}

</script>
<style>

.xx{
    display: flex;
}
</style>